package chapter2.No2_1_synchronized同步方法.g出现异常锁自动释放;

/**
 * !
 *
 * @author liujian
 * @version 2016/11/11 0011
 */
public class TestObject {

    public synchronized void methodA() {
        String name = Thread.currentThread().getName();
        if("a".equals(name)) {
            try {
                System.out.println("A线程开始");
                Integer.parseInt("a");
                Thread.sleep(2000);
                System.out.println("A线程结束");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }else{
            System.out.println("其他线程开始");
            System.out.println("其他线程结束");
        }
    }
}
